import { Notification } from 'element-ui'

const resCode = {
  res: 200
}
// 商品上架成功
export function goodsCreate (response) {
  const { data } = response
  if (response.status === resCode.res && response.config.url === 'admin/goods/create') {
    Notification({
      title: data.errmsg,
      message: '商品上架成功',
      type: 'success'
    })
  }
}
// 数据删除成功
export function goodsDelete (response) {
  const { data } = response
  if (response.status === 200 && response.config.url === 'admin/goods/delete') {
    Notification({
      title: data.errmsg,
      message: '数据删除成功',
      type: 'success'
    })
  }
}
// 登录
export function authLogin (response) {
  const { data } = response
  if (response.status === resCode.res && response.config.url === 'admin/auth/login') {
    Notification({
      title: data.errmsg,
      message: data.errmsg === '成功' ? '登录成功' : '失败',
      type: data.errmsg === '成功' ? 'success' : 'warning'
    })
  }
}
// 回复
export function orderReply (response) {
  const { data } = response
  if (response.status === resCode.res && response.config.url === 'admin/order/reply') {
    Notification({
      title: data.errmsg,
      message: data.errmsg === '成功' ? '回复成功' : '失败',
      type: data.errmsg === '成功' ? 'success' : 'warning'
    })
  }
}
